package com.twoGroup.boot.utils;

//import org.junit.Test;

import com.twoGroup.boot.controller.AddressController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DESUtils {
    public static Logger logger = LoggerFactory.getLogger(DESUtils.class);
    private char[] charNum = {0,1,2,3,4,5,6,7,8,9};
    private char[] charLetterA = {'a','b','c','d','e','f','g','h','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    private char[] charLetterB = {'A','B','C','D','E','F','G','H','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

    public char[] getCharNum() {
        return charNum;
    }

    public static void encryption(String str){
        char[] charNum = {0,1,2,3,4,5,6,7,8,9};
        String[] charStr = new String[(str.length()*2)-1];
            // 1,2,3,4,5
        //给每位数后面加上一个  ','
        int j = 0;
        for (int i = 0; i <str.length() ; i++) {
            if(i%2!=0){
                charStr[i] = String.valueOf(str.charAt(j++));
                logger.info(charStr[i]+":"+str.charAt(j++));
            }else{
                charStr[i]= String.valueOf(',');
                logger.info(i+"：："+charStr[i]+"--->");
            }
        }

        //for循环将数字转换成二进制数
        for (int i = 0; i <str.length() ; i++) {
            for (char c : charNum) {
                if (i % 2 != 0) {
                    if (charStr[i].equals(String.valueOf(c))) {
                        //数字的话转换成二进制  字母的话就不管了
                        charStr[i] = Integer.toBinaryString(Integer.parseInt(charStr[i]));
                    }
                }
            }
        }

        for (String s : charStr) {
            System.out.print(s);
        }



    }

    public static void decrypt(){}

//    @Test
    public void test(){
        encryption("123456789");
    }
}
